import React, { Component } from "react";
import { Input } from "antd";

class index extends Component {
  add = (e) => {
    if (e.keyCode === 13) {
      this.props.addItem(this.refs.input.state.value)
      // 清空输入框
      this.refs.input.state.value = " ";
    }
  };
  render() {
    return (
      <div>
        <Input
          ref="input"
          onKeyUp={this.add}
          placeholder="请输入你的任务名称，回车键确认添加~"
        />
      </div>
    );
  }
}

export default index;
